const textarea = document.getElementById("text-input");
const counter = document.getElementById("char-count");

textarea.addEventListener("input", () => {
  const length = +textarea.value.length;
  if (length === 50) counter.style.color = "red";
  if (length <= 50) counter.textContent = `Character Count: ${length}/50`;
  else {
    textarea.value = textarea.value.slice(0,50);
  }
})